import {
    getUserInfo
} from "@/api"

const state = {
    userInfo: {}
}

const actions = {
    async getUserInfo({
        commit
    }, token) {
        const result = await getUserInfo(token);
        if (result.code == 200) {
            commit('GET_USER_INFO', result.userInfo);
        }
    }
}

const mutations = {
    GET_USER_INFO(state, userInfo) {
        state.userInfo = userInfo;
    }
}

const getters = {
    userInfo(state) {
        return state.userInfo || {}
    }
}

export default {
    state,
    actions,
    mutations,
    getters
}